package com.longxi.tianjintianbao.ui.adapter.multitype.maintain;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.greedao.entity.Patrol;
import com.longxi.tianjintianbao.model.maintain.Maintain;
import com.longxi.tianjintianbao.utils.TimeComparisonUtils;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by cxw on 2018/2/20.
 */
public class MaintainDetailViewBinder extends ItemViewBinder<Maintain, MaintainDetailViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_maintain_detail, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Maintain maintain) {
        holder.mTvEquipName.setText("设备名称:" + maintain.getEquipmentname());
        holder.mTvEquipAddress.setText("设备位置:" + maintain.getBelong().replace("\\", " ") + maintain.getEquipmentaddress());
        holder.mTvDateperiod.setText("保养日期:" + maintain.getMaintaindate());

//        if("0".equals(patrol.getApplicant())){
//            holder.mTvApplicant.setVisibility(View.VISIBLE);
//            holder.mTvApplicant.setText("完成情况:" + "未在规定时间内完成");
//        }else if("2".equals(patrol.getApplicant())){
//            holder.mTvApplicant.setVisibility(View.VISIBLE);
//            holder.mTvApplicant.setText("完成情况:" + "按时完成");
//        }else{
//            holder.mTvApplicant.setVisibility(View.GONE);
//        }
//
//        if("0".equals(patrol.getState())){
//            holder.mTvState.setVisibility(View.VISIBLE);
//            holder.mTvState.setText("设备状态:" + "异常");
//        }else if("1".equals(patrol.getState())){
//            holder.mTvState.setVisibility(View.VISIBLE);
//            holder.mTvState.setText("设备状态:" + "正常");
//        }else{
//            holder.mTvState.setVisibility(View.GONE);
//        }
//
//        if(patrol.getExplain() != null){
//            holder.mTvExplain.setVisibility(View.VISIBLE);
//            holder.mTvExplain.setText("完成说明:" + patrol.getExplain());
//        }else{
//            holder.mTvExplain.setVisibility(View.GONE);
//        }
//
//        if(patrol.getReleasetime() != null){
//            holder.mTvReleasetime.setVisibility(View.VISIBLE);
//            holder.mTvReleasetime.setText("完成时间:" + patrol.getReleasetime());
//        }

    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView mTvEquipName;
        TextView mTvEquipAddress;
        TextView mTvEquipStaff;
        TextView mTvDateperiod;

        TextView mTvApplicant;
        TextView mTvState;
        TextView mTvExplain;
        TextView mTvReleasetime;

        ViewHolder(View itemView) {
            super(itemView);
            mTvEquipName = itemView.findViewById(R.id.tvEquipName);
            mTvEquipAddress = itemView.findViewById(R.id.tvEquipAddress);
            mTvEquipStaff = itemView.findViewById(R.id.tvEquipStaff);
            mTvDateperiod = itemView.findViewById(R.id.tvDateperiod);

            mTvApplicant = itemView.findViewById(R.id.tvApplicant);
            mTvState = itemView.findViewById(R.id.tvState);
            mTvExplain = itemView.findViewById(R.id.tvExplain);
            mTvReleasetime = itemView.findViewById(R.id.tvReleasetime);
        }
    }
}
